package leetcode.L1000;

import java.util.Comparator;
import java.util.PriorityQueue;

public class EX1046 {
    public static void main(String[] args) {
        int [] stones = {2,7,4,1,8,1};

        PriorityQueue<Integer> heap = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
        for (int i = 0; i < stones.length; i++) {
            heap.add(stones[i]);
        }
        while (heap.size()>1){
            int a = heap.poll();
            int b = heap.poll();

            if(a-b!=0){
                heap.add(a-b);
            }
        }




    }
}
